package nio.socket.block;

/**
 * 通过线程池对IO阻塞的服务器端进行优化
 * 缺点是访问量大且单个请求处理时间长会造成线程池中的线程被耗尽，大量请求被阻塞等待
 */
public class ThreadPoolServerTest {
    private static int port = 9998;
    private static String host = "127.0.0.1";

    public static void main(String[] args) throws InterruptedException {
        new Thread(()->{
            ThreadPoolServer.start(port);
        },"server").start();

        Thread.sleep(1000);

        new Thread(()->{
            Client.post(host,port,3000);
        },"client1").start();

        new Thread(()->{
            Client.post(host,port,3000);
        },"client2").start();
    }
}
